<%@page contentType="text/html; charset=utf-8" language="java" %>
<%@page import="biz.UserBiz" %>
<%@page import="bean.User" %>
<%
if(session.getAttribute("uid") == null){
	out.print("<script>alert('请先登录！');history.back();</script>");
	response.sendRedirect("login.jsp");
}
User user = UserBiz.getUserByUid(Integer.parseInt(session.getAttribute("uid").toString()));
String action = request.getParameter("action");
if((action != null) && action.equals("ui")){
	user.setUemail(request.getParameter("email"));
	user.setUname(request.getParameter("uname"));
	user.setUinfo(request.getParameter("info"));
	boolean flag = UserBiz.updateUserByUser(user);
	if(flag){
		session.setAttribute("uid",user.getUid());
		out.print("<script>alert('更新成功，即将转向您的页面！');history.back();</script>");
		response.sendRedirect("user.jsp");
	}else{
		out.print("<script>alert('有重名用户了，换个名字吧！');history.back();</script>");
	}
}
%>
<html>
	<head>
	<link href="css.css" rel="stylesheet" type="text/css">
		<title>更新我的帐户信息</title>
	</head>
	<body>
	<jsp:include page="/head.jsp"/>
		<center><fieldset>
			<p class="f_title">更新我的信息</p>
			<div class="disc">您可以在这里修改您的个人信息，更改密码请点击<a href="updatepass.jsp">这里</a></div>
			<form method="post" action="updateuser.jsp?action=ui">
				<ol>
				<li><label for="uname"><span id="blank">&nbsp;&nbsp;</span>用户名：</lable><span><input type="text" name="uname" value="<%=user.getUname()%>" class="input" style="width:180px;"></span></li>
				<li><label for="email">电子邮件：</label><span><input type="text" name="email" value="<%=user.getUemail()%>" class="input" style="width:180px;"></span></li>
				<li><label for="info"><span id="blank">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="vertical-align:top">签名：</span></label><span><textarea type="text" name="info" class="input" style="width:180px;height:8em;"><%=user.getUinfo()%></textarea></span></li>
				</ol>
				<input type="submit" value="我要更新" style="width:80px" class="button"/>
				<input type="reset" value="重填" style="width:60px" class="button"/>	
			</form>
		</fieldset></center>
	<jsp:include page="/copyright.html"/>
	</body>
</html>